<#import "/spring.ftl" as spring />
<#import "html-macro.ftl" as h />
<#import "declaration-macro.ftl" as d />
<#if d.isSupplierPage__>
<script type="text/javascript" src="<@spring.url "/js/gtimp3/declaration.js"/>"></script>
<div class="row">
    <div class="column">
        <button id="returnBtn" class="tiny ui labeled icon button blue">
            <i class="fa-arrow-left icon"></i>
            返回
        </button>
        <#if '${declaration.state}'=="DS01">
            <button id="toValidBtn" class="tiny ui labeled icon button blue">
                <i class="plus icon"></i>
                受理
            </button>
            <button id="toRejectBtn" class="tiny ui labeled icon button blue">
                <i class="save icon"></i>
                驳回
            </button>
        </#if>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $(".button-line").remove();
        $goodsForm.show();
        $("#toValidBtn").click(function () {
            ajaxGet('<@spring.url "../business/doValid?id=${declaration.id}"  />',
                    function (result) {
                        layer.alert(result.msg, function (index) {
                            layer.close(index);
                            window.location.href = '../business/toValidMain';
                        });
                    });
        });
        $("#toRejectBtn").click(function () {
            var url = "<@spring.url "../business/toReject?id=${declaration.id}"  />";

            var iWidth = 500;
            var iHeight = 300;
            var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
            var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
            var win = window.open(url, "弹出窗口",
                                  "width=" + iWidth + ", height=" + iHeight + ",top=" + iTop
                                  + ",left=" + iLeft
                                  + ",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,alwaysRaised=yes,depended=yes");

        });
    });
</script>
<#else >
<div class="row">
    <div class="column">
        <button id="returnBtn" class="tiny ui labeled icon button blue">
            <i class="small fa-arrow-left icon"></i>
            返回
        </button>
        <button id="copyBtn" class="tiny ui labeled icon button blue">
            <i class="small copy icon"></i>
            复制
        </button>
        <#if d.isDraft__>
            <button id="editBtn" class="tiny ui labeled icon button blue">
                <i class="fa-pencil-square-o icon"></i>
                修改
            </button>
            <button id="submitBtn" class="tiny ui labeled icon button blue">
                <i class="small fa-check icon"></i>
                提交
            </button>
        </#if>
        <#if d.isOrder__ && declaration.payment_type != "1">
            <button id="payBtn" class="tiny ui labeled icon button blue">
                <i class="small copy icon"></i>
                支付
            </button>
        </#if>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $goodsForm.show();
    });
</script>
</#if>
<script type="text/javascript">
    $(document).ready(function () {
    <#if d.isDraft__>
        $("#editBtn").click(function () {
            location.href = "<@spring.url "/order/update" />?id=${declaration.id}";
        });
    </#if>
    <#if d.isOrder__>
        $("#payBtn").click(function () {
            location.href = "<@spring.url "/order/payPage" />?id=${declaration.id}";
        });
    </#if>
        $("#returnBtn").click(function () {
            history.go(-1);
        });
    });
</script>